package cn.doitedu.vueapi.dao.tg;


import org.apache.ibatis.annotations.*;
import org.apache.ibatis.jdbc.SQL;
import cn.doitedu.vueapi.pojo.tg.AdFeePay;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.util.List;

@Component
public interface AdFeePayMapper{

	@SelectProvider(type = SqlProvider.class, method = "selectByAdFeePay")
	@ResultMap("BaseResultMap")
	List<AdFeePay> selectByAdFeePay(AdFeePay adFeePay);

	@InsertProvider(type = SqlProvider.class,method = "insertAdFeePay")
	int insertAdFeePay(AdFeePay adFeePay);

	@UpdateProvider(type = SqlProvider.class,method = "updateAdFeePay")
	int updateAdFeePay(AdFeePay adFeePay);

	@DeleteProvider(type = SqlProvider.class,method = "deleteAdFeePay")
	int deleteAdFeePay(AdFeePay adFeePay);



	 class SqlProvider{
	
		public String selectByAdFeePay(AdFeePay adFeePay){
			SQL sql= new SQL().SELECT("*").FROM("`ad_fee_pay`");
			if(adFeePay.getAdid()!=null) sql.AND().WHERE("`adid`="+adFeePay.getAdid());
			if(adFeePay.getUid()!=null) sql.AND().WHERE("`uid`="+adFeePay.getUid());
			if(adFeePay.getPayedPvs()!=null) sql.AND().WHERE("`payed_pvs`="+adFeePay.getPayedPvs());
			if(adFeePay.getPayedFee()!=null) sql.AND().WHERE("`payed_fee`="+adFeePay.getPayedFee());
			if(adFeePay.getCreateTime()!=null) sql.AND().WHERE("`create_time`="+adFeePay.getCreateTime());
			if(adFeePay.getUpdateTime()!=null) sql.AND().WHERE("`update_time`="+adFeePay.getUpdateTime());
	
			return sql.toString();
		}
		public String insertAdFeePay(AdFeePay adFeePay){
			SQL sql= new SQL().INSERT_INTO("`ad_fee_pay`");
			if(adFeePay.getAdid()!=null) sql.VALUES("`adid`",String.valueOf(adFeePay.getAdid()));
			if(adFeePay.getUid()!=null) sql.VALUES("`uid`",String.valueOf(adFeePay.getUid()));
			if(adFeePay.getPayedPvs()!=null) sql.VALUES("`payed_pvs`",String.valueOf(adFeePay.getPayedPvs()));
			if(adFeePay.getPayedFee()!=null) sql.VALUES("`payed_fee`",String.valueOf(adFeePay.getPayedFee()));
			if(adFeePay.getCreateTime()!=null) sql.VALUES("`create_time`",String.valueOf(adFeePay.getCreateTime()));
			if(adFeePay.getUpdateTime()!=null) sql.VALUES("`update_time`",String.valueOf(adFeePay.getUpdateTime()));
			return sql.toString();	
		}
		public String updateAdFeePay(AdFeePay adFeePay){
			SQL sql= new SQL().UPDATE("`ad_fee_pay`");
			if(adFeePay.getAdid()!=null) sql.SET("`adid`=" + adFeePay.getAdid());
			if(adFeePay.getUid()!=null) sql.SET("`uid`=" + adFeePay.getUid());
			if(adFeePay.getPayedPvs()!=null) sql.SET("`payed_pvs`=" + adFeePay.getPayedPvs());
			if(adFeePay.getPayedFee()!=null) sql.SET("`payed_fee`=" + adFeePay.getPayedFee());
			if(adFeePay.getCreateTime()!=null) sql.SET("`create_time`=" + adFeePay.getCreateTime());
			if(adFeePay.getUpdateTime()!=null) sql.SET("`update_time`=" + adFeePay.getUpdateTime());
			sql.WHERE("`adid`="+adFeePay.getAdid());
			return sql.toString();	
		}
		public String deleteAdFeePay(AdFeePay adFeePay){
			SQL sql= new SQL().DELETE_FROM("`ad_fee_pay`");
			if(adFeePay.getAdid()!=null) sql.AND().WHERE("`adid`=" + adFeePay.getAdid());
			if(adFeePay.getUid()!=null) sql.AND().WHERE("`uid`=" + adFeePay.getUid());
			if(adFeePay.getPayedPvs()!=null) sql.AND().WHERE("`payed_pvs`=" + adFeePay.getPayedPvs());
			if(adFeePay.getPayedFee()!=null) sql.AND().WHERE("`payed_fee`=" + adFeePay.getPayedFee());
			if(adFeePay.getCreateTime()!=null) sql.AND().WHERE("`create_time`=" + adFeePay.getCreateTime());
			if(adFeePay.getUpdateTime()!=null) sql.AND().WHERE("`update_time`=" + adFeePay.getUpdateTime());
			return sql.toString();	
		}
	}
	
}